package com.hzhr.iot.device.controller;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.Author;
import com.hzhr.iot.core.dto.ResponseExceptionDto;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.device.controller.base.BaseController;
import com.hzhr.iot.device.model.regulatorDevice_infoCard.RegulatorDevice_InfoCardGetModel;
import com.hzhr.iot.device.model.regulatorDevice_infoCard.RegulatorDevice_InfoCardPutModel;
import com.hzhr.iot.device.service.RegulatorDevice_InfoCardService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@Api(tags = "RegulatorDevice_InfoCard", description = "调压设备的信息卡片")
@RestController
@RequestMapping(value = "")
public class RegulatorDevice_InfoCardController extends BaseController {
    @Autowired
    RegulatorDevice_InfoCardService regulatorDevice_infoCardService;

    //region /regulator-devices/{regulatorDeviceId}/info-cards/{id} PUT
    //region swagger响应码 : putByRegulatorDeviceIdAndId
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
            @ApiResponse(code = 403, message = "----异常代码 : 201  \n----异常类型 : 业务流程异常  \n----异常业务 : 查询信息卡片  \n----异常说明 : 信息卡片不存在  \n\n", response = ResponseExceptionDto.class),
    })
    //endregion
    //region swagger说明 : putByRegulatorDeviceIdAndId
    @ApiOperation(value="根据调压设备编号和信息卡片编号编辑调压设备下的信息卡片", notes="根据调压设备编号和信息卡片编号编辑调压设备下的信息卡片  \n简介 : 根据调压设备编号和信息卡片编号编辑调压设备下的信息卡片  \n步骤 :  \n1. 查询信息卡片 :  \n 根据路径参数regulatorDeviceId和id查询信息卡片(DEVICE_INFO_CARD)deviceInfoCard_1，  \n 路径参数筛选规则如下：  \n (1) deviceInfoCard_1.id = 路径参数id；  \n (2) deviceInfoCard_1.deviceExt.id = 路径参数regulatorDeviceId；  \n 额外筛选规则如下：  \n (1) deviceInfoCard_1.deviceExt.categoryCode = REGULATOR_BOX or USER_REGULATOR_TANK or SOURCE_REGULATOR_TANK；  \n 如果deviceInfoCard_1不存在，抛出异常201；  \n2. 修改信息卡片 :  \n 根据body修改deviceInfoCard_1的相关信息；  \n3. 返回信息 :  \n 根据条件参数查询修改后的deviceInfoCard_1的信息生成结果对象并返回；  \n",produces = "application/json")
    //endregion
    //region swagger参数 : putByRegulatorDeviceIdAndId
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "regulatorDeviceId", value = "调压设备编号",required = true, dataType = "int", paramType = "path"),
            @ApiImplicitParam(name = "id", value = "信息卡编号",required = true, dataType = "int", paramType = "path"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_device", value = "是否展示设备信息", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_device", value = "是否展示设备信息", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    //endregion
    //region 请求 : putByRegulatorDeviceIdAndId
    @RequestMapping(value = "/regulator-devices/{regulatorDeviceId}/info-cards/{id}", method = RequestMethod.PUT)
    //endregion
    @Author
    public ResponseEntity<RegulatorDevice_InfoCardGetModel> putByRegulatorDeviceIdAndId(@PathVariable("regulatorDeviceId") Integer regulatorDeviceId, @PathVariable("id") Integer id,
                                                                    @RequestParam @ApiIgnore Map<String, Object> query,
                                                                    @RequestBody RegulatorDevice_InfoCardPutModel body) throws ServiceException {
        RegulatorDevice_InfoCardGetModel responseBody = regulatorDevice_infoCardService.putByRegulatorDeviceIdAndId(initHeader(), regulatorDeviceId, id, query, body);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
    //region /regulator-devices/{regulatorDeviceId}/info-cards GET
    //region swagger响应码 : get
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : get
    @ApiOperation(value="根据调压设备编号查询该调压设备的信息卡片", notes="根据调压设备编号查询该调压设备的信息卡片  \n简介 : 根据调压设备编号查询该调压设备的信息卡片  \n步骤 :  \n1. 查询信息卡片 :  \n 根据条件参数和路径参数regulatorDeviceId查询信息卡片(DEVICE_INFO_CARD)deviceInfoCard_1，  \n 路径参数筛选规则如下：  \n (1) deviceInfoCard_1.deviceId = 路径参数regulatorDeviceId；  \n 额外筛选规则如下：  \n (1) deviceInfoCard_1.deviceExt.categoryCode = REGULATOR_BOX or USER_REGULATOR_TANK or SOURCE_REGULATOR_TANK；  \n2. 返回信息 :  \n 根据deviceInfoCard_1及条件参数生成结果对象result并返回，  \n 其中DeviceInfoCardModel模型的managementName、subCompanyName属性的设置方法如下：  \n 使用GLOBAL方式调用deptService.get服务获取DeptModel模型进行相关设置，DeviceInfoCardModel模型与DeptModel模型的对应关系如下：  \n (1) DeviceInfoCardModel模型的deptId属性对应于DeptModel模型的id属性(一对一)；  \n (2) DeviceInfoCardModel模型的managementName属性对应于DeptModel模型的managementName属性；  \n (3) DeviceInfoCardModel模型的subCompanyName属性对应于DeptModel模型的subCompanyName属性；  \n",produces = "application/json")
    //endregion
    //region swagger参数 : get
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "regulatorDeviceId", value = "调压设备编号",required = true, dataType = "int", paramType = "path"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_device", value = "是否展示设备信息", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "equal_id", value = "筛选条件 : where regulatorDevice_infoCard.id = #{equal_id}",required = false, dataType = "int", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_device", value = "是否展示设备信息", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_equal_id", value = "筛选条件 : where regulatorDevice_infoCard.id = #{_equal_id}",required = false, dataType = "int", paramType = "query"),

    })
    //endregion
    //region 请求 : get
    @RequestMapping(value = "/regulator-devices/{regulatorDeviceId}/info-cards", method = RequestMethod.GET)
    //endregion
    @Author
    public ResponseEntity<RegulatorDevice_InfoCardGetModel> get(@PathVariable("regulatorDeviceId") Integer regulatorDeviceId,
                                                             @RequestParam @ApiIgnore Map<String, Object> query) throws ServiceException {
        RegulatorDevice_InfoCardGetModel responseBody = regulatorDevice_infoCardService.get(initHeader(), regulatorDeviceId, query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
}


































































































































































